<% add_decidim_page_title(t("info", scope: "decidim.admin.menu.initiatives_submenu")) %>
<% add_decidim_page_title(translated_attribute(current_participatory_space.title)) %>
<div class="item_show__header">
  <h1 class="item_show__header-title">
    <%= t("info", scope: "decidim.admin.menu.initiatives_submenu") %>
  </h1>
</div>

<div class="item__edit item__edit-1col">
  <div class="item__edit-form">
    <%= decidim_form_for @form, html: { class: "form-defaults form edit_initiative" } do |f| %>
      <%= render partial: "form", object: f %>
      <div class="item__edit-sticky">
        <div class="item__edit-sticky-container">
          <%= f.submit t(".update"), class: "button button__sm button__secondary" if allowed_to? :update, :initiative, initiative: current_initiative %>

            <% if allowed_to? :send_to_technical_validation, :initiative, initiative: current_initiative %>
              <%= link_to t(".send_to_technical_validation"),
                          send_to_technical_validation_initiative_path(current_initiative),
                          class: "button button__sm button__secondary",
                          data: { confirm: t(".confirm_send_to_technical_validation") } %>
            <% elsif current_initiative.created? %>
              <%= link_to t(".send_to_technical_validation"), "#", class: "button button__sm button__secondary" %>
            <% end %>

            <% if allowed_to? :publish, :initiative, initiative: current_initiative %>
              <%= link_to t("actions.publish", scope: "decidim.admin"),
                          publish_initiative_path(current_initiative),
                          method: :post,
                          class: "button button__sm button__secondary",
                          data: { confirm: t(".confirm") } %>
            <% end %>

            <% if allowed_to? :unpublish, :initiative, initiative: current_initiative %>
              <%= link_to t("actions.unpublish", scope: "decidim.admin"),
                          unpublish_initiative_path(current_initiative),
                          method: :delete,
                          class: "button button__sm button__secondary",
                          data: { confirm: t(".confirm") } %>
            <% end %>

            <% if allowed_to? :accept, :initiative, initiative: current_initiative %>
                <%= link_to t(".accept"),
                            accept_initiative_path(current_initiative),
                            method: :post,
                            class: "button button__sm button__secondary",
                            data: { confirm: t(".confirm") } %>
            <% end %>

            <% if allowed_to? :reject, :initiative, initiative: current_initiative %>
                <%= link_to t(".reject"),
                            reject_initiative_path(current_initiative),
                            method: :delete,
                            class: "button button__sm button__secondary",
                            data: { confirm: t(".confirm") } %>
            <% end %>

            <% if allowed_to? :discard, :initiative, initiative: current_initiative %>
              <%= link_to t(".discard"),
                          discard_initiative_path(current_initiative),
                          method: :delete,
                          class: "button button__sm button__secondary",
                          data: { confirm: t(".confirm") } %>
            <% end %>

            <% if allowed_to? :export_votes, :initiative, initiative: current_initiative %>
              <%= link_to t(".export_votes"),
                          export_votes_initiative_path(current_initiative, format: :csv),
                          class: "button button__sm button__secondary",
                          data: { confirm: t(".confirm") } %>
            <% end %>

            <% if allowed_to? :export_pdf_signatures, :initiative, initiative: current_initiative %>
              <%= link_to t(".export_pdf_signatures"),
                          export_pdf_signatures_initiative_path(current_initiative, format: :pdf),
                          class: "button button__sm button__secondary" %>
            <% end %>
       </div>
     </div>
    <% end %>
  </div>
</div>
